package com.im.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.im.app.mapper.WelcomeMapper;
import com.im.app.model.Welcome;
import com.im.app.service.WelcomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 欢迎语(Welcome)表服务实现类
 *
 * @author makejava
 * @since 2023-03-20 14:21:46
 */
@Service
@Transactional(rollbackFor = Exception.class)
@Slf4j
public class WelcomeServiceImpl implements WelcomeService {

    @Resource
    private WelcomeMapper welcomeMapper;
    @Override
    public List<Welcome> queryWelcomeList() {
        //分页
//        Page<Welcome> rowPage = new Page(1, 10);
//        Page<Welcome> welcomePage = welcomeDao.selectPage(rowPage, new QueryWrapper<Welcome>().orderByDesc("create_time"));
        List<Welcome> welcomeList = welcomeMapper.selectList(new QueryWrapper<Welcome>().orderByDesc("create_time"));
        return welcomeList;
    }

    @Override
    public Welcome findWelcome(Integer id) {
        return welcomeMapper.selectById(id);
    }

    @Override
    public int deleteWelcome(Integer id) {
        return welcomeMapper.deleteById(id);
    }

    @Override
    public int addWelcome(Welcome welcome) {
        return welcomeMapper.insert(welcome);
    }

    @Override
    public int updateWelcome(Welcome welcome) {
        return welcomeMapper.updateById(welcome);
    }


}

